<template>
    <box left="50px"
         top="60px"
         title="净收入">
        <div class='lefttop'>
            <my-marquee :info="info.info"></my-marquee>
            <my-title></my-title>
            <div ref="chart"
                 class="chart"></div>
        </div>
    </box>

</template>

<script>
export default {
    props: {
        info: {},
    },
    components: {},
    data() {
        return {}
    },
    watch: {
        info: {
            handler(newVal) {
                this.chartInit(
                    newVal.tmChartData,
                    newVal.jdChartData,
                    newVal.xData
                )
            },
            deep: true,
        },
    },
    computed: {},
    methods: {
        chartInit(tmData, jdData, xData) {
            let _chart = this.$echarts.init(this.$refs['chart'])
            let _options = {
                grid: {
                    top: '40',
                    right: '20',
                    left: '30',
                    bottom: '30', //图表尺寸大小
                },
                legend: {
                    textStyle: {
                        color: '#8fadcc',
                        fontSize: 12,
                    },
                    itemWidth: 8,
                    itemHeight: 8,
                    icon: 'circle',
                    right: 0,
                    top: 10,
                },
                tooltip: {},
                xAxis: {
                    type: 'category',
                    color: '#59588D',
                    data: xData,
                    axisLabel: {
                        margin: 8,
                        color: '#8fadcc',
                        textStyle: {
                            fontSize: 12,
                        },
                    },
                    axisLine: {
                        lineStyle: {
                            color: 'rgba(255,255,255,0.1)',
                        },
                    },
                    axisTick: {
                        show: false,
                    },
                    splitLine: {
                        show: false,
                    },
                },
                yAxis: [
                    {
                        name: '万元',
                        nameTextStyle: {
                            padding: [50, -50, -20, -10],
                            color: '#8fadcc',
                        },
                        axisLabel: {
                            color: '#8fadcc',
                            textStyle: {
                                fontSize: 8,
                            },
                        },
                        axisLine: {
                            show: true,
                            lineStyle: {
                                color: 'rgba(255,255,255,0.1)',
                            },
                        },
                        axisTick: {
                            show: false,
                        },
                        splitLine: {
                            show: false,
                        },
                    },
                ],
                series: [
                    {
                        type: 'bar',
                        name: '同期',
                        data: tmData,
                        barWidth: '6',
                        barGap: '80%',
                        itemStyle: {
                            normal: {
                                color: new this.$echarts.graphic.LinearGradient(
                                    0,
                                    0,
                                    0,
                                    1,
                                    [
                                        {
                                            offset: 0,
                                            color: 'rgba(51,185,255,1)',
                                        },
                                        {
                                            offset: 1,
                                            color: 'rgba(12,29,100,1)',
                                        },
                                    ]
                                ),
                                barBorderRadius: [30, 30, 0, 0], //圆角大小
                            },
                        },
                        label: {
                            normal: {
                                show: false,
                                fontSize: 16,
                                fontWeight: 'bold',
                                color: '#333',
                                position: 'top',
                            },
                        },
                    },
                    {
                        type: 'bar',
                        name: '实际',
                        data: jdData,
                        barWidth: '6',
                        barGap: '80%',
                        itemStyle: {
                            normal: {
                                color: new this.$echarts.graphic.LinearGradient(
                                    0,
                                    0,
                                    0,
                                    1,
                                    [
                                        {
                                            offset: 0,
                                            color: '#14ca8f',
                                        },
                                        {
                                            offset: 1,
                                            color: '#053c48',
                                        },
                                    ]
                                ),
                                barBorderRadius: [30, 30, 0, 0], //圆角大小
                            },
                        },
                        label: {
                            normal: {
                                show: false,
                                fontSize: 16,
                                fontWeight: 'bold',
                                color: '#333',
                                position: 'top',
                            },
                        },
                    },
                ],
            }
            _chart.setOption(_options)
        },
    },
    mounted() {},
}
</script>
<style lang='less' scoped>
.chart {
    width: 400px;
    height: 225px;
}
</style>